import dashboard from './modules/dashboard';
import BasicLayout from '@/layouts/basic-layout';
import setting from './modules/setting';
import report from './modules/report';
import userSetting from './modules/userSetting';
import clue from './modules/clue';
import newClue from './modules/newClue';
import clique from './modules/clique';
import robot from './modules/robot';
import weChart from './modules/weChart';
import marketing from './modules/marketing';

/**
 * 在主框架内显示
 */
const frameIn = [{
    path: '/',
    redirect: {
        name: 'dashboard'
    },
    component: BasicLayout,
    children: [{
        path: 'log',
        name: 'log',
        meta: {
            title: '前端日志',
            auth: true
        },
        component: () => {
            return import('@/pages/system/log');
        }
    },
    // 刷新页面 必须保留
    {
        path: 'refresh',
        name: 'refresh',
        hidden: true,
        component: {
            beforeRouteEnter(to, from, next) {
                next((instance) => {
                    return instance.$router.replace(from.fullPath);
                }
                );
            },
            render: (h) => {
                return h();
            }
        }
    },
    // 页面重定向 必须保留
    {
        path: 'redirect/:route*',
        name: 'redirect',
        hidden: true,
        component: {
            beforeRouteEnter(to, from, next) {
                next((instance) => {
                    return instance.$router.replace(
                        JSON.parse(from.params.route)
                    );
                }
                );
            },
            render: (h) => {
                return h();
            }
        }
    },
    {
        path: '/business/diseases/:id',
        name: 'diseases',
        meta: {
            title: '病种专题',
            auth: true
        },
        component: () => {
            return import('@/pages/diseases');
        }
    },
    {
        path: '/business/patient',
        name: 'patient',
        meta: {
            title: '患者',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/patient');
        }
    },
    {
        path: '/business/newClue1',
        name: 'newClue1',
        meta: {
            title: '线索',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/newClue1');
        }
    },
    {
        path: '/business/filterClue',
        name: 'filterClue',
        meta: {
            title: '过滤线索',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/filterClue');
        }
    },
    {
        path: '/business/diseasecheck',
        name: 'diseasecheck',
        meta: {
            title: '病种核验',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/diseasecheck');
        }
    },
    {
        path: '/business/losspatients',
        name: 'losspatients',
        meta: {
            title: '流失患者',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/losspatients');
        }
    },
    {
        path: '/business/marketreferral',
        name: 'marketreferral',
        meta: {
            title: '市场转诊',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/marketreferral');
        }
    },
    {
        path: '/business/returnVisit',
        name: 'returnVisit',
        meta: {
            title: '回访',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/returnVisit');
        }
    },
    {
        path: '/business/guide',
        name: 'guide',
        meta: {
            title: '导医',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/guide');
        }
    },
    {
        path: 'business/network',
        name: 'network',
        meta: {
            title: '网络',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/network');
        }
    },
    {
        path: '/business/allocation',
        name: 'allocation',
        meta: {
            title: '分配',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/allocation');
        }
    },
    {
        path: '/business/publicList',
        name: 'publicList',
        meta: {
            title: '公海',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/publicList');
        }
    },
    {
        path: '/business/fishPond',
        name: 'fishPond',
        meta: {
            title: '鱼池',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/fishPond');
        }
    },    
    {
        path: '/business/recycle',
        name: 'recycle',
        meta: {
            title: '回收站',
            auth: true,
            keepAlive: true
        },
        component: () => {
            return import('@/pages/recycle');
        }
    },
        // {
        //   path: "tasks",
        //   name: "tasks",
        //   meta: {
        //     title: "计划任务",
        //     auth: true,
        //   },
        //   component: () => import("@/pages/tasks"),
        // },
    ]
},
    report,
    setting,
    clue,
    dashboard,
    clique,
    weChart,
    robot,
    userSetting,
    newClue,
    marketing
];

/**
 * 在主框架之外显示
 */

const frameOut = [{
    path: '/clueform',
    name: 'clueform',
    meta: {
        title: '线索表单'
    },
    component: () => {
        return import('@/pages/clueform');
    }
},
    
    // 登录
    {
        path: '/login',
        name: 'login',
        meta: {
            title: '$t:page.login.title'
        },
        component: () => {
            return import('@/pages/account/login');
        }
    },
    // 注册
    {
        path: '/register',
        name: 'register',
        meta: {
            title: '$t:page.register.title'
        },
        component: () => {
            return import('@/pages/account/register');
        }
    }
    
];

/**
 * 错误页面
 */

const errorPage = [// 线索表单
{
    path: '/403',
    name: '403',
    meta: {
        title: '403'
    },
    component: () => {
        return import('@/pages/system/error/403');
    }
},
{
    path: '/500',
    name: '500',
    meta: {
        title: '500'
    },
    component: () => {
        return import('@/pages/system/error/500');
    }
},
{
    path: '*',
    name: '404',
    meta: {
        title: '404'
    },
    component: () => {
        return import('@/pages/system/error/404');
    }
}
];

// 导出需要显示菜单的
export const frameInRoutes = frameIn;

// 重新组织后导出
export default [...frameIn, ...frameOut, ...errorPage];
